﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace QLBH
{
    [Serializable]
    class DSanPham: List<CSanpham>, ISP
    {
        //Load Sản Phẩm
        public void Load(string filePath)
        {
            Stream str = File.Open(filePath, FileMode.Open);
            BinaryFormatter bFormatter = new BinaryFormatter();
            ISP list_Sp = (ISP)bFormatter.Deserialize(str);
            str.Close();

            this.Clear();
            foreach (CSanpham Sp in list_Sp)
            {
                this.Add(Sp);
            }
        }
        //lưu sản phẩm
        public void Save(string filePath)
        {
            Stream str = File.Open(filePath, FileMode.Create);
            BinaryFormatter bFormater = new BinaryFormatter();
            bFormater.Serialize(str, this);
            str.Close();
        }
    }
}
